<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
    <input type="file" id="file" onchange="readFile(this)">

    <img src="" id="img">
    <script>
        function readFile(obj) {
            console.log(obj.files[0]);
            // var fileReader = new FileReader()
            document.querySelector("#img").src = URL.createObjectURL(obj.files[0]);
        }
    </script>
</body>

</html>